#!/bin/bash

tf="rep.cnf.feel"
tfk="rep.cnf.128.bak"
rm -rf $tf $tfk

for rip in `seq 43 58`
do
    ip=`printf "172.24.65.%d" $rip`

    for rdb in `seq 0 1` # change to <0, 1> for table level
    do
        let dbx=(rip-43)*2+rdb
        db=`printf "feel_%02d" $dbx`
#        db=`printf "feel_%02d,feel_%02d" $dbx $(($dbx+1))`
#       echo "master|$ip|3306|fm$db|$db|feed_auc_count_|dump|dump123|mysql-bin.00000|/u01/drc_mysql" | tee -a $tfk
        for rtbl in `seq 0 3`
        do
            let tblx=4*dbx+rtbl
            tbl=`printf feed_auc_count_%04d $tblx`
            echo "master|$ip|3306|M:$db:$tbl|$db|$tbl|dump|dump123|mysql-bin.00000|106|/u01/cm5_rep" | tee -a $tfk
        done
    done
done
echo "slave|172.25.89.28|3306|S:feel:feed_auc_count_xxx|cm5_feel|cm5_feel|repsync|repsync123|0|0" | tee -a $tfk


start=1
row_diff=7
let end=start+row_diff

while read line 
do
    binfile=`echo "$line" | cut -f1`
    binpos=`echo "$line" | cut -f2`
    cat $tfk | sed -n "${start},${end}p" | sed "s/mysql-bin.00000|/${binfile}|/; s/106|/${binpos}|/"  | tee -a $tf
    let start=end+1
    let end=start+row_diff
done < "sync_pos.log"

tail -1 $tfk >> $tf
